<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<%--流程图表--%>
<%--<div id="flowChart" style="width: 860px;height: 400px;margin:30px 0;"></div>--%>
<form:form commandName="task" cssClass="form-horizontal" role="form" onsubmit="return false;">
    <h3 style="margin: 0px 0px 10px 0;">当前项目详情</h3>
    <div class="form-group">
        <div class="col-sm-12">
            <textarea rows="2" id="projectDetail" name="taskContent" placeholder="项目详情（主要问题）" readonly
                      class="form-control ">${projectDetail}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right" for="record_addTackLog">反馈记录</label>
        <div class="col-sm-11">
            <textarea rows="3" id="record_addTackLog" name="record" placeholder="填写攻坚过程中的反馈记录"
                      class="form-control " required></textarea>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right">反馈材料</label>
        <input class="col-sm-3" type="file" id="fileupload" name="files"/>
        <button class="col-sm-2 btn btn-large btn-primary" id="btn-upload">上传</button>
    </div>
    <div class="form-group">
        <label class="col-sm-12" style="color: red;">点击确定添加攻坚记录！(如需上传材料，请先上传材料再点击确定)</label>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label no-padding-right">当前情况</label>
        <div class="col-sm-3">
            <input type="text" id="result" value="" class="form-control" readonly>
        </div>
        <label class="col-sm-1 control-label no-padding-right" for="tackFlag">选择办结</label>
        <div class="col-sm-3">
            <select name="tackFlag" id="tackFlag" class="form-control">
                <option value="">--请选择--</option>
                <option value="1">暂不办结，只提交反馈</option>
                <option value="2">立即办结</option>
            </select>
        </div>
        <label class="col-sm-1 control-label no-padding-right" for="finishTackDate">办结时间</label>
        <div class="col-sm-3">
            <input type="text" name="finishTackDate" id="finishTackDate" placeholder="如办结，请选择办结时间"
                   autocomplete="off" class="form-control date-picker" >
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-10" style="color: red;">如需办结任务，请务必填写反馈情况，供审核人员参考作出审核！</label>
        <div class="col-sm-2">
            <button class="btn btn-large btn-warning" id="finishTack_btn">提交处理</button>
        </div>
    </div>
    <%--<input type="text" name="taskId" id="taskId" value="${task.sysId}" hidden>--%>
    <input type="text" name="taxproof" id="taxproof_proof" hidden>
    <form:hidden path="sysId"/>

</form:form>
<hr width="100%; height:2px;" style="margin: 0;" >
<div class="row" style="margin-left: 2px;">
    * 以上按住如此标志：<img src="/assets/web/img/zzc.png"  alt="提示" />可拖动调整相应输入框大小
</div>
<script src="<s:url value="/assets/js/ajaxfileupload.js"></s:url>"></script>
<script type="text/javascript">

    jQuery(function($) {
        $('.date-picker').datepicker({
            inline: true,
            format:"yyyy-mm-dd",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        }).next().on(ace.click_event, function(){
            $(this).prev().focus();
        });
    });

    /**
     * 上传材料
     */
    $("#btn-upload").click(function () {
        var fileval = $("#fileupload").val();
        if (fileval == null || fileval == "") {
            alert("未选择任何文件");
            return;
        }
        $(".shade").fadeIn(100);
        $(".warning").fadeIn(100);
        $('.la-square-jelly-box').show();
        showShade();
        //警告框自定义内容
        $('.warning>.title>em').html('加载中……');
        $.ajaxFileUpload({
            type: "post",
            fileElementId: "fileupload",
            secureuri: false,
            dataType: 'text',
            url: "/communal/uploadBatch",
            async: false,
            success: function (data) {

                var data = JSON.parse(data);
                var val = data.data.sysid;
                $("#taxproof_proof").attr("value", val);
                if (data.code === "200") {
                    $('.warning>.title>em').html('上传成功');
                } else {
                    $('.warning>.title>em').html('上传失败');
                }
            },
            error: function () {
                alert("佐证材料上传失败 ！！请联系管理员");
            }
        });
    });
    var tackFlag = ${task.tackFlag};
    if (tackFlag == "1") {
        $("#result").val("未办结");
    }else if(tackFlag == "2") {
        $("#result").val("已确认办结，审核中");
    }else{
        $("#result").val("已办结");
    }
    $("#finishTack_btn").click(function () {
        var tackFlag = $("#tackFlag").val();
        if(tackFlag == ""){
            alert("请选择办结结果！");
            return false;
        }
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("finishTack"),
            tableId: "#gridTable",
            successMessage: "提交成功",
            successTitle: '保存对话框',
            //failMessage: '保存失败',
            failTitle: '消息对话框'
        });
        //倒计时
        // var btn = document.getElementById("submit");
        // btn.disabled = true
        // countdown(5);
        window.location.href = "/taskToTack";
    })

</script>